package com.example.werthwedemo0309.fragment;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.werthwedemo0309.R;

import java.util.List;

public class Aadapter extends RecyclerView.Adapter<Aadapter.holder> {
    private List<Amodel> data;

    public void setData(List<Amodel> data) {
        this.data = data;
    }

    private Context context;

    public Aadapter(Context context) {
        this.context = context;
    }

    @Override
    public holder onCreateViewHolder(@NonNull  ViewGroup parent, int viewType) {
        return new Aadapter.holder(LayoutInflater.from(context).inflate(R.layout.list_item,null));
    }

    @Override
    public void onBindViewHolder(@NonNull Aadapter.holder holder, int position) {
        holder.list_city.setText(data.get(position).getCity());
    }

    @Override
    public int getItemCount() {
        return null!=data?data.size():0;
    }

    class holder extends RecyclerView.ViewHolder{
        TextView list_city;

        public holder(@NonNull View itemView) {
            super(itemView);
            list_city=itemView.findViewById(R.id.list_city);
        }
    }
}
